package com.bawei.bydayzg_two.payFragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.bawei.base.mvvm.BaseFragment
import com.bawei.bydayzg_two.R
import com.bawei.bydayzg_two.adapter.OrderAdapter
import com.bawei.bydayzg_two.databinding.FragmentOrder1Binding
import com.bawei.bydayzg_two.databinding.FragmentOrder3Binding
import com.bawei.bydayzg_two.viewModel.OrderViewModel
import com.blankj.utilcode.util.ToastUtils

class OrderFragment3 : BaseFragment<FragmentOrder3Binding, OrderViewModel>() {
    lateinit var orderAdapter: OrderAdapter
    //
    override fun getLoutyId(): Int {
        return R.layout.fragment_order3
    }

    override fun getViewModel(): Class<OrderViewModel> {
        return OrderViewModel::class.java
    }

    override fun initView() {

        //
        orderAdapter = OrderAdapter()
        binding.order1Rv.adapter = orderAdapter
        binding.order1Rv.layoutManager = LinearLayoutManager(context)
        //
        viewModel.order("2",20,1)
    }

    override fun initDate() {

        //
        viewModel.orderSuccess.observe(this){
            if (it.code == 200){
                orderAdapter.data.clear()
                orderAdapter.data.addAll(it.data.list)
                orderAdapter.notifyDataSetChanged()
            }
            //
            ToastUtils.showLong(it.message)
        }
    }

}